/********************************************************************************
 *      Copyright:  (C) 2022 lijiale
 *                  All rights reserved.
 *
 *       Filename:  comport.h
 *    Description:  This head file 
 *
 *        Version:  1.0.0(12/01/22)
 *         Author:  lijiale
 *      ChangeLog:  1, Release initial version on "12/01/22 20:39:30"
 *                 
 ********************************************************************************/

#ifndef __COMPORT_H_
#define __COMPORT_H_

#include <termios.h>
#include <unistd.h>

#define SERLALNAME 64

typedef struct comport_s
{
    int             fd;       //串口文件描述符
    int             baudrate; //波特率
    int             databits; //数据位
    int             mSend_Len;//单次最大发送长度
    char            parity;   //奇偶校验位
    int             stopbits; //停止位
    char            settings[SERLALNAME]; //"8n1n"
    char            tty_name[SERLALNAME];//串口名称
    char            modelname[SERLALNAME];//型号：“BC28”
    struct termios  oldtermios; //串口原始属性
}comport_t;

int comport_conf(comport_t *comport);
int comport_close(comport_t *comport);
int comport_open(comport_t *comport,char *devname);
int comport_recv(comport_t *comport,char *rbuf,int rbuf_len,int timeout);
int comport_send(comport_t *comport,char *sbuf,int sbuf_len);

#endif
